#ifndef ZL_REGEX_PURE
#define ZL_REGEX_PURE

#include "RegexAutomaton.h"

namespace zl
{
	namespace regex_internal
	{
		class PureResult
		{
		public:
			zint				start;
			zint				length;
			zint				finalState;
			zint				terminateState;
		};

		class PureInterpretor : public Object
		{
		protected:
			zint				charMap[1<<(4*sizeof(wchar_t))];	// char -> char set index
			zint**				transition;			// (state * char set index) -> state*
			bool*				finalState;			// state -> bool
			zint*				relatedFinalState;		// sate -> (finalState or -1)
			zint				stateCount;
			zint				charSetCount;
			zint				startState;
		public:
			PureInterpretor(Automaton::Ref dfa, CharRange::List& subsets);
			~PureInterpretor();

			bool				MatchHead(const wchar_t* input, const wchar_t* start, PureResult& result);
			bool				Match(const wchar_t* input, const wchar_t* start, PureResult& result);
			zint				GetStartState();
			zint				Transit(wchar_t input, zint state);
			bool				IsFinalState(zint state);
			bool				IsDeadState(zint state);
			void				PrepareForRelatedFinalStateTable();
			zint				GetRelatedFinalState(zint state);
		};
	};
};
#endif
